package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportRecordEquipmentOperateDto;
import com.yqg.protection.entity.RecordEquipmentOperate;
import com.yqg.protection.mapper.RecordEquipmentOperateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 10:26
 * description:
 */
@Component
public class RecordEquipmentOperateListener extends AnalysisEventListener<ImportRecordEquipmentOperateDto> {

    @Autowired
    private RecordEquipmentOperateMapper recordEquipmentOperateMapper;

    @Override
    public void invoke(ImportRecordEquipmentOperateDto importRecordEquipmentOperateDto, AnalysisContext analysisContext) {
        RecordEquipmentOperate recordEquipmentOperate = new RecordEquipmentOperate();
        BeanUtil.copyProperties(importRecordEquipmentOperateDto, recordEquipmentOperate, true);
        recordEquipmentOperate.setIsDelete(0);
        recordEquipmentOperateMapper.insert(recordEquipmentOperate);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
